package com.zoran.study.spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.*;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.concurrent.Executor;

@SpringBootApplication
@ImportResource({ "classpath:/spring/applicationContext.xml" })
@ComponentScan(basePackages = {"com.zoran.study.spring"})
@PropertySources({@PropertySource(value = "classpath:db.properties")})
@EnableAutoConfiguration
@EnableWebMvc
@EnableAspectJAutoProxy
public class StudySpringApplication {

	public static void main(String[] args) {
		SpringApplication.run(StudySpringApplication.class, args);
	}


    @Bean
    public TaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.initialize();
        taskExecutor.setThreadNamePrefix("AsyncExecutor-");
        taskExecutor.setCorePoolSize(8);
        return taskExecutor;
    }
}
